fix(autotests): do not remove read-only files already removed
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 17 Apr 2025 17:21:49 +0000 (19:21 +0200)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 24 Apr 2025 09:01:34 +0000 (11:01 +0200)
the sync engine will remove invalid items inside read-only folders

not needed to remove them in tests and rather checks that they were
indeed removed

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
test/testpermissions.cpp

index 6bd3723fa87dd641e4bff2138913e1218886518c..38970d8ef1d03beef8e674a18ffcd2c4bec6c5cf 100644 (file)
@@ -141,7 +141,7 @@ private slots:
                 const auto result = FileSystem::remove(fileInfoToDelete.absoluteFilePath(), &errorString);
                 if (!result) {
                     qDebug() << "fail to delete:" << fileInfoToDelete.absoluteFilePath() << errorString;
-                    //QVERIFY(result);
+                    QVERIFY(result);
                 }
             } else {
                 const auto result = FileSystem::removeRecursively(fileInfoToDelete.absoluteFilePath());
@@ -282,8 +282,6 @@ private slots:
         // The file should not exist on the remote, and not be there
         QVERIFY(!currentLocalState.find("readonlyDirectory_PERM_M_/newFile_PERM_WDNV_.data"));
         QVERIFY(!fakeFolder.currentRemoteState().find("readonlyDirectory_PERM_M_/newFile_PERM_WDNV_.data"));
-        // remove it so next test succeed.
-        removeReadOnly("readonlyDirectory_PERM_M_/newFile_PERM_WDNV_.data");
         // Both side should still be the same
         QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
 
@@ -365,8 +363,8 @@ private slots:
         QVERIFY(currentLocalState.find("readonlyDirectory_PERM_M_/subdir_PERM_CK_/subsubdir_PERM_CKDNV_/normalFile_PERM_WVND_.data" ));
         // new no longer exists
         QVERIFY(!currentLocalState.find("readonlyDirectory_PERM_M_/newname_PERM_CK_/subsubdir_PERM_CKDNV_/normalFile_PERM_WVND_.data" ));
-        // but is not on server: so remove it locally for the future comparison
-        removeReadOnly("readonlyDirectory_PERM_M_/newname_PERM_CK_");
+        // but is not on server: should have been locally removed
+        QVERIFY(!currentLocalState.find("readonlyDirectory_PERM_M_/newname_PERM_CK_"));
 
         //2.
         // old removed
@@ -375,8 +373,8 @@ private slots:
         QVERIFY(fakeFolder.currentRemoteState().find("normalDirectory_PERM_CKDNV_/subdir_PERM_CKDNV_"));
         // new no longer exists
         QVERIFY(!currentLocalState.find("readonlyDirectory_PERM_M_/moved_PERM_CK_/subsubdir_PERM_CKDNV_/normalFile_PERM_WVND_.data" ));
-        //but not on server
-        removeReadOnly("readonlyDirectory_PERM_M_/moved_PERM_CK_");
+        // should have been cleaned up as invalid item inside read-only folder
+        QVERIFY(!currentLocalState.find("readonlyDirectory_PERM_M_/moved_PERM_CK_"));
         fakeFolder.remoteModifier().remove("normalDirectory_PERM_CKDNV_/subdir_PERM_CKDNV_");
 
         QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());